#include <stdlib.h>
#include <pthread.h>
#include <semaphore.h>
#include <unistd.h>
#include <string.h>

struct _task_t;
typedef struct _task_t *task_t;

typedef struct {
  int val;
  task_t waiters_head;
  task_t waiters_tail;
} task_sem_t;

int task_create (task_t *t, void *(*start_routine) (void *), void *arg);
void task_cooperate ();
void *main_task (void *);

int task_sem_init (task_sem_t *sem, int val);
int task_sem_post (task_sem_t *sem);
int task_sem_wait (task_sem_t *sem);
int task_sem_destroy (task_sem_t *sem);

void task_send (task_t * t, char * mot, int taille);


void task_receive (char * mot, int taille);
void task_ns_register (task_t* pt, char * mot);
